<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Hais丶定制 - 用户详情</title>
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
    <link href="css/sb-admin-2.min.css" rel="stylesheet">
</head>

<body id="page-top">

<div id="wrapper">
    <div id="content-wrapper" class="d-flex flex-column">

        <!-- Main Content -->
        <div id="content">

            <!-- Content Row -->
            <div class="row">

                <!-- Earnings (Monthly) Card Example -->
                <div class="col-xl-3 col-md-6 mb-4">
                    <div class="card border-left-primary shadow h-100 py-2">
                        <div class="card-body">
                            <div class="row no-gutters align-items-center">
                                <div class="col mr-2">
                                    <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">未制作完的</div>
                                    <div class="h5 mb-0 font-weight-bold text-gray-800" id="waitNum">..</div>
                                </div>
                                <div class="col-auto">
                                    <i class="fas fa-calendar fa-2x text-gray-300"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Earnings (Monthly) Card Example -->
                <div class="col-xl-3 col-md-6 mb-4">
                    <div class="card border-left-success shadow h-100 py-2">
                        <div class="card-body">
                            <div class="row no-gutters align-items-center">
                                <div class="col mr-2">
                                    <div class="text-xs font-weight-bold text-success text-uppercase mb-1">我已定制的</div>
                                    <div class="h5 mb-0 font-weight-bold text-gray-800" id="finshNum">..</div>
                                </div>
                                <div class="col-auto">
                                    <i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Earnings (Monthly) Card Example -->
                <div class="col-xl-3 col-md-6 mb-4">
                    <div class="card border-left-info shadow h-100 py-2">
                        <div class="card-body">
                            <div class="row no-gutters align-items-center">
                                <div class="col mr-2">
                                    <div class="text-xs font-weight-bold text-info text-uppercase mb-1">剩余定制次数</div>
                                    <div class="row no-gutters align-items-center">
                                        <div class="col-auto">
                                            <div class="h5 mb-0 mr-3 font-weight-bold text-gray-800" id="moneyNum">..</div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-auto">
                                    <i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Pending Requests Card Example -->
                <div class="col-xl-3 col-md-6 mb-4">
                    <div class="card border-left-warning shadow h-100 py-2">
                        <div class="card-body">
                            <div class="row no-gutters align-items-center">
                                <div class="col mr-2">
                                    <div class="text-xs font-weight-bold text-warning text-uppercase mb-1">进Q群交流</div>
                                    <div class="h5 mb-0 font-weight-bold text-gray-800">927251103</div>
                                </div>
                                <div class="col-auto">
                                    <i class="fas fa-comments fa-2x text-gray-300"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- DataTales Example -->
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary" id="title">定制列表</h6>
                    </div>

                    <div class="table-responsive">
                        <table class="table table-bordered table-hover" id="dataTable" width="100%" cellspacing="0">
                            <thead>
                            <tr align="center">
                                <th>状态/机器</th>
                                <th>机型/版本</th>
                                <th>提交/用户</th>
                            </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>

                </div>

        </div>

        <footer class="sticky-footer bg-white">
            <div class="container my-auto">
                <div class="copyright text-center my-auto">
                    <span>Copyright © 2020-2021 hais.pw</span>
                </div>
            </div>
        </footer>
    </div>
</div>
<a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
</a>

<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>

<!-- Custom scripts for all pages-->
<script src="js/sb-admin-2.min.js"></script>
<script>
    $.ajax({
        type: "get",
        data: "random="+Math.random(),
        url: "http://api.hais.pw/user/get",
        dataType: "json",
        beforeSend: function (XMLHttpRequest) {
            XMLHttpRequest.setRequestHeader("Authorization", 'Bearer '+localStorage.getItem("user_token"));
        },
        success: function(data) {
            console.log(data);
            $('#moneyNum').text(data.money+'次')
        },
        error: function(data) {

        }
    });
    $.ajax({
        type: "get",
        data: "random="+Math.random(),
        url: "http://api.hais.pw/miui/make/home?userId="+localStorage.getItem("user_id"),
        dataType: "json",
        success: function(data) {
            $("#waitNum").text(data.waitNum+data.doMakeNum)
            $("#finshNum").text(data.finshNum)
        },
        error: function(data) {

        }
    });

    loadMakeList('');
    function loadMakeList(type) {
         var user =JSON.parse(localStorage.getItem("user"));
        $.ajax({
            type: "get",
            data: "random=" + Math.random(),
            url: "http://api.hais.pw/miui/make/make-list?step="+type+"&pageNum=1&keyword="+user.id,
            dataType: "json",
            beforeSend: function (XMLHttpRequest) {
                XMLHttpRequest.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem("user_token"));
            },
            success: function (data) {
                console.log(data.records);
                $('tbody').empty();
                jQuery.each(data.records, function(i,item){
                    var createobj = $('<tr align="center" onclick="window.open(\'make-info.html?id='+item.id+'\',\'_self\')">\n' +
                        '<td><small>'+item.doStepStr+'</small></td>\n' +
                        '<td><small>'+item.deviceId+'<br/>'+item.romVersion+'</small></td>\n' +
                        '<td><small>'+item.timeStr+'<br/>'+item.userId+'</small></td>\n' +
                        '</tr>'); //把div定义为变量createobj
                    $("tbody").append(createobj);
                });
            },
            error: function (data) {

            }
        });
    }

</script>

</body>

</html>
